#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
    pid_t id = fork();
    assert(id != -1);
    if(id == 0) //子进程
    {
        printf("i am child process\n");
        sleep(5);
        exit(0);
    }
    int status;

    int a = waitpid(id,&status,0);
    assert(a != -1);
    
    printf("ExitCode:%d , Signal:%d , Coredump:%d\n",(status>>8)&0xFF,status&0x7F,(status>>7)&1);
    return 0;
}
